package imPro;

import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;
import javax.imageio.ImageIO;

/**
 *
 * @author Ragnar
 */
public class HandleClient implements Runnable
{
    private BufferedImage image;
    private Socket socket;
    
    public HandleClient(Socket socket, Common src)
    {
        this.socket = socket;
        this.image = (BufferedImage) src.getImage();
    }
    
    public void run()
    {
        try
        {
            ObjectOutputStream output = new ObjectOutputStream(this.socket.getOutputStream());
            
            while (true) 
            {
                ImageIO.write(image, "JPEG", output);
                System.out.println("Object sent");
                Thread.sleep(50);
            }
        }
        catch(IOException e) 
        {
            System.err.println(e.getMessage());
        }
        catch (InterruptedException e) {}
    }
}
